<template>
    <div class="main">
        <div class="main-header" style="justify-content: space-between;">
            <!-- <el-button
                v-for="(item, index) in buttons"
                :key="index"
                :type="item.path | formatType"
                :icon="item.icon"
                :disabled="item.path | formatDisabled(selection)"
                @click="tapButton(item)"
                >{{ item.title }}</el-button
            > -->
            <div style="display: flex;">
              <!--  <el-input placeholder="请输入内容" style="width: 200px;margin-right: 10px;" v-model="searchParamCp.keyword" size="mini" clearable>
                </el-input> -->
				<!-- payStatus  再加个支付状态  0未支付  1已支付 -->
				<!-- <el-select v-model="searchParamCp.payStatus" size="mini" placeholder="请选择支付状态"
					style="width: 200px;margin-right: 10px;">
					<el-option v-for="(item,index) in paylist" :key="index" :label="item" :value="index">
					</el-option>
				</el-select> -->
				<el-select v-model="searchParamCp.parkKey" size="mini" placeholder="请选择停车场"
					style="width: 200px;margin-right: 10px;">
					<el-option v-for="(item,index) in parkKeylist" :key="item.id" :label="item.title" :value="item.id">
					</el-option>
				</el-select>
              <!--  <div class="timepick" style="margin-right: 10px;">
                    <el-date-picker clearable v-model="searchParamCp.createtime" value-format="yyyy-MM-dd" size="mini" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                    </el-date-picker>
                </div> -->
                <el-button type="primary" size="mini" @click="searchs()">搜索</el-button>
                <el-button size="mini" @click="reset()">重置</el-button>
            </div>
        </div>
        <el-table ref="table" class="main-table" :data="memberData" height="100%" border header-cell-class-name="main-table-header" @selection-change="onSelectionChange">
            <!-- <el-table-column type="selection" width="39"></el-table-column> -->
            <el-table-column  align="center" label="车场唯一编号" prop="parkKey" />
            <el-table-columnalign="center" label="车道编号" prop="vehNumber" />
            <el-table-column align="center"  label="岗亭编号" prop="sentryboxNo" />
            <el-table-column align="center"  label="车场规模" prop="parkScale" />
            <el-table-column align="center"  label="车道类型" prop="vehType" />
            <el-table-column align="center" label="车道名称" prop="vehName" />
			<el-table-column prop="parkCode" align="center" label="二维码">
			    <template slot-scope="{ row }">
			        <el-image style="width:50px;height:50px;" fit="contain" :src="'https://zdcloud.zxkjnc.com'+row.parkCode"
			            :preview-src-list="['https://zdcloud.zxkjnc.com'+row.parkCode]"></el-image>
			    </template>
			</el-table-column>
			<!-- <el-table-column align="center" label="车道小程序码" prop="parkCode" /> -->
			<!-- <el-table-column align="center" width="120px" label="车道名称" prop="vehName" /> -->
			<!--  1 pos余额支付 2 帐户余额支付 3 微信支付 -->
			<!-- <el-table-column align="center" label="支付方式" prop="payType">
			    <template slot-scope="{row}">
			        <el-tag v-if="row.payType==1">pos余额支付</el-tag>
			        <el-tag v-if="row.payType==2" type="success">帐户余额支付</el-tag>
			        <el-tag v-if="row.payType==3" type="info">微信支付</el-tag>
			    </template>
			</el-table-column> -->
			<!-- payStatus  再加个支付状态  0未支付  1已支付 -->
			<!-- <el-table-column align="center" label="支付状态" prop="payStatus">
			    <template slot-scope="{row}">
			        <el-tag v-if="row.payType==0">未支付</el-tag>
			        <el-tag v-if="row.payType==1" type="success">已支付</el-tag>
			    </template>
			</el-table-column>
            <el-table-column align="center" label="进场时间" prop="addtime">
                <template slot-scope="{row}">
                    {{row.enterTime}}
                </template>
            </el-table-column> -->
            <el-table-column align="center" label="同步时间" prop="addtime">
                <template slot-scope="{row}">
					<div v-if="row.addtime">{{getTime(row.addtime)}}</div>
                   
                </template>
            </el-table-column>
        </el-table>
        <el-pagination class="main-pagination" :current-page.sync="page" :page-size="limit" :total="total" @current-change="onCurrentChange" layout="total,jumper,prev,pager,next"></el-pagination>
    </div>
</template>

<script>
import {
    get, post
} from "@/assets/js/http.js";
import { Result } from "element-ui";
export default {
    name: "view-freeca",
    data() {
        return {
            memberData: [],
            searchParamCp: {},
            searchinfo: {
                parkKey: '',
                // createtime: [],
				// payStatus:'',
				// payType:'',
            },
            page: 1,
            limit: 20,
            total: 0,
			paylist:['未支付','已支付'],//payStatus  再加个支付状态  0未支付  1已支付 
			paytype:[{id:1,title:'优生活支付'},{id:2,title:'帐户余额支付'},{id:3,title:'微信支付'}],// 1 pos余额支付 2 帐户余额支付 3 微信支付
			parkKeylist:[{id:'9h298ctj',title:'后广场停车场'},{id:'1kebvqjq',title:'地面停车场'},{id:'4be9aag4',title:'地库停车场'},],
			//后广场停车场 9h298ctj 地面停车场 1kebvqjq 地库停车场 4be9aag4
        }
    },
    mounted() {
        this.getTableList()
    },
    methods: {
		getTime(time) {
			let date = new Date(time * 1000)
			let year = date.getFullYear()
			let month = date.getMonth() + 1
			let day = date.getDate()
			// 时分秒
			let hour = date.getHours()
			let minute = date.getMinutes()
			let second = date.getSeconds()
			return `${year}-${month}-${day} ${hour}:${minute}:${second}`
		},
        searchs() {
            this.page = 1
            this.searchinfo = {
                ...this.searchinfo,
                ...this.searchParamCp
            }
            console.log(this.searchinfo, '....搜索');
			this.getTableList()
        },
        reset() {
            this.page = 1
            this.searchParamCp = {}
            this.searchinfo = {
                parkKey: ''
            }
			this.getTableList()
        },
        onSelectionChange(selection) {
            this.selection = selection;
        },
        async getTableList() {
            const data = await get({
                url: '/admin/car.CarPark/index',
                params:{
					...this.searchinfo,
					page: this.page,
					limit: this.limit
				} ,
                loading: true,
            });
            const list = data.list
            this.total = data.total;
            this.memberData = list
        },
        onCurrentChange(index) {
            this.page = index;
            this.$nextTick(() => {
                this.getTableList();
            })
        },
    }
}
</script>
